
import { AppContext, AppState, AppConfig } from 'ROOT/interface/App';

import { AUTHORITY } from 'ROOT/constants/common';
import { outLogger } from 'ROOT/common/logger';

/**
 * 判断是不是管理员
 */
export default async (ctx: AppContext, next: () => Promise<void> ) => {

    // 拿到token
    if (ctx.state.user?.role == AUTHORITY.admin) {
        await next();
        return;
    }
    ctx.sendError({ code: 401, message: 'No Authorization'});
    return;
};
